﻿module RPG {
    export class Preloader extends Phaser.State {
        preload() {
            var loadingText = this.game.add.text(this.game.world.centerX, this.world.centerY, 'Loading...', { font: "70px Arial", fill: "#ffffff", align: 'center' });
            loadingText.anchor.setTo(0.5);

            //Preload World Map
            this.game.load.tilemap('world_map', 'Graphics/Environment/Controls/worldmap.json', null, Phaser.Tilemap.TILED_JSON);
            this.game.load.image('terrain_tiles', 'Graphics/Environment/tileset_1.png');
            this.game.load.image('mountain_tiles', 'Graphics/Environment/mountains_0.png');
            this.game.load.image('water_tiles', 'Graphics/Environment/water_1.png');

            //Load Hero
            this.load.spritesheet('Hero', 'Graphics/Sprites/Hero.png', 16, 16, 24);

            //Load environment sprites
            this.load.spritesheet('Portal', 'Graphics/Sprites/portal.png', 32, 32, 8);

            //Preload Levels
            //Preload Tileset for Levels
            this.game.load.image('town_tiles', 'Graphics/Environment/town_tiles.png');

            //Level 1
            this.game.load.tilemap('level1_map', 'Graphics/Environment/Controls/Levels/level1map.json', null, Phaser.Tilemap.TILED_JSON);

        }

        create() {
            this.game.state.start('WorldMap', true, false);
        }
    }
}